package config

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	MysqlYun
	ALiYun
	BaiDuYun
}
type MysqlYun struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
}
type ALiYun struct {
	AccessKeyID     string
	AccessKeySecret string
	AccessCn        string
}
type BaiDuYun struct {
	APIKey    string
	SecretKey string
}

var AppConf AppConfig

func InitsConfig() {
	viper.SetConfigFile("./config/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		print(err)
		return
	}
	fmt.Println("配置读取信息成功")
	err = viper.Unmarshal(&AppConf)
	if err != nil {
		print(err)
		return
	}
	fmt.Println(AppConf)
	fmt.Println("配置解析信息成功")
}
